<!-- 列表item通用组件 -->
<template>
	<view class="c_item" :class="{'nather': source !== 'course'}">
		<view v-for="(item,index) in dataList" class="item" @click="$emit('goDetail',item)">
			<view class="inner" :style="{
				backgroundImage: `url(${item.coverImg || item.courseCover})`
			}">
				<view class="top">
					<view class="left">
						<avatar class="avatar" :src="item.lecturerHead"></avatar>
					</view>
					<view class="right">
						<view class="title" :class="{'clamp2':source !== 'course'}">{{item.resourceName || item.courseName}}(共{{item.resourceNum}}节)</view>
						<!-- 课程 -->
						<view class="content clamp2" v-if="source === 'course'">{{item.courseSynopsis}}</view>
						<!-- 历史/课程详情 -->
						<view class="content" v-else-if="source === 'history'">{{item.isBuy}}</view>
						<!-- 收藏 -->
						<view class="content" v-else :class="item.money == '免费'? 'yes' :'no'">{{item.money}}</view>
					</view>
				</view>

				<view class="bot">
					<view class="left">
						<text>讲师:</text>
						<text class="teacher">{{item.lecturerName}}</text>
					</view>
					<view class="right">
						<view class="look">
							<image src='https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/mine/look.png'></image>
							<text>{{item.watchNum}}</text>
						</view>
						<view class="zan">
							<image src='https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/mine/zan.png'></image>
							<text>{{item.greatNum}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import avatar from '@/components/avatar.vue'
	export default {
		components: {
			avatar
		},
		props: {
			dataList: {
				type: Array,
				default: () => []
			},
			//来源
			source: {
				type: String,
				default: ''
			}
		}
	}
</script>

<style lang="scss" scoped>
	.c_item {
		width: 100%;
		height: 100%;
		padding: 8rpx 32rpx 0 30rpx;
		background-color: #F8F8F8;

		.item {
			position: relative;
			width: 100%;
			height: fit-content;
			border-radius: 20rpx;
			margin-top: 26rpx;
			overflow: hidden;



			.inner {
				width: 100%;
				height: fit-content;
				padding: 30rpx;
				box-sizing: border-box;
				background-position: 0 0;
				background-size: 100% 100%;
				background-repeat: no-repeat;

				&::after {
					content: '';
					display: block;
					position: absolute;
					top: 0;
					left: 0;
					right: 0;
					bottom: 0;
					height: 100%;
					background-color: #fff;
					opacity: .3;
				}

				.top {
					display: flex;
					justify-content: space-between;

					.left {
						margin-right: 30rpx;

						.avatar {
							width: 140rpx;
							height: 140rpx;
						}
					}

					.right {
						.title {
							color: #111111;
							font-size: 30rpx;
							font-weight: bold;
						}

						.content {
							font-size: 28rpx;
							height: 76rpx;
							width: 438rpx;
							margin-top: 30rpx;
							color: #5F5F5F;
						}
					}
				}

				.bot {
					margin-top: 26rpx;
					display: flex;
					font-size: 26rpx;
					justify-content: space-between;

					.left {
						.teacher {
							color: #656565;
							margin-left: 20rpx;
						}
					}

					.right {
						display: flex;
						align-items: center;
						color: #656565;

						.look {
							margin-right: 20rpx;
						}
					}

					image {
						width: 26rpx;
						height: 18rpx;
						margin-right: 4rpx;
					}
				}
			}
		}
	}

	.nather {
		.item {
			background-color: #fff;

			.top {
				.left {
					image {
						width: 220rpx;
						height: 146rpx;
						border-radius: 10rpx;
					}
				}

				.right {
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.content {
						margin: 0;
						height: auto
					}

					.yes {
						font-size: 36rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #194FC9;
					}

					.no {
						font-size: 32rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #FFA025;
					}

					.title {
						height: 74rpx;
						width: 374rpx;
					}
				}
			}

			.bot {}
		}
	}
</style>
